package com.demo.controller;



import com.demo.annotation.GlobalInterceptor;
import com.demo.annotation.VerifyParam;
import com.demo.entity.enums.PermissionCodeEnum;
import com.demo.entity.po.DeviceInventory;

import com.demo.entity.query.DeviceInventoryQuery;


import com.demo.entity.vo.ResponseVO;


import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import com.demo.service.DeviceInventoryService;


@RestController
@RequestMapping("/device")
public class DeviceInventoryController extends ABaseController {

	@Resource
	private DeviceInventoryService deviceInventoryService;


	/**
	 * 分页查询
	 */
	@RequestMapping("/loadInventoryList")
	@GlobalInterceptor(permissionCode = PermissionCodeEnum.DEVICE_LIST)
	public ResponseVO loadInventoryList(DeviceInventoryQuery query) {
		return getSuccessResponseVO(deviceInventoryService.findListByPage(query));
	}


	/**
	 * 编辑库存明细
	 */
	@RequestMapping("/saveInventory")
	@GlobalInterceptor(permissionCode = PermissionCodeEnum.DEVICE_INVENTORY_EDIT)
	public ResponseVO saveInventory(DeviceInventory bean) {
		this.deviceInventoryService.saveInventory(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据InventoryId删除
	 */
	@RequestMapping("/delInventory")
	@GlobalInterceptor(permissionCode = PermissionCodeEnum.DEVICE_INVENTORY_DEL)
	public ResponseVO delInventory(@VerifyParam(required = true) Integer inventoryId) {
		this.deviceInventoryService.deleteDeviceInventoryByInventoryId(inventoryId);
		return getSuccessResponseVO(null);
	}
}